{
  "properties" : { },
  "id" : "copy1723794840330d87918",
  "script" : null,
  "groupId" : "c0cf605f74e34bc6953194a869f4a6cd",
  "name" : "B2查询气象站实时天气情况",
  "createTime" : null,
  "updateTime" : 1733896977827,
  "lock" : null,
  "createBy" : "admin",
  "updateBy" : "admin",
  "path" : "/stationweather",
  "method" : "GET",
  "parameters" : [ {
    "name" : "regioncode",
    "value" : "",
    "description" : "行政区划编码查询 不填查全部",
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  }, {
    "name" : "time",
    "value" : "",
    "description" : "数据可以按找小时获取  yyyy-MM-ddTHH:00:00   不填写取最终数据",
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  }, {
    "name" : "stationkey",
    "value" : "",
    "description" : "站点编号 不填查全部",
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  }, {
    "name" : "orgid",
    "value" : "",
    "description" : "系统机构ID",
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  } ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"code\": 0,\n    \"message\": \"success\",\n    \"data\": [],\n    \"timestamp\": 1733896966467,\n    \"executeTime\": 15\n}",
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : {
    "name" : "",
    "value" : "",
    "description" : "",
    "required" : false,
    "dataType" : "Object",
    "type" : null,
    "defaultValue" : null,
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ {
      "name" : "code",
      "value" : "0",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "message",
      "value" : "success",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "data",
      "value" : "",
      "description" : "",
      "required" : false,
      "dataType" : "Array",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "timestamp",
      "value" : "1729477783550",
      "description" : "",
      "required" : false,
      "dataType" : "Long",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "executeTime",
      "value" : "6",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    } ]
  }
}
================================
import org.ssssssss.script.parsing.ast.statement.Return
/**
 *   按照机构号码查询、
 *  @param   regioncode  行政区划编码查询不填查全部
 *  @param   time        时间格式数据可以按找小时获取  yyyy-MM-ddTHH:00:00   不传查最新 传查指定时间  必须传入整点数据
 *  @param   stationkey  查询指定站点编码
 */
 
var sql = """
    select t1.*,i.orgid from stationdata_hour t1  
    join( select stationKey ,max(timeBase) as latest_timestamp 
    from stationdata_hour
    where 1 = 1 
    <if test="regioncode != null and regioncode != ''" > and code LIKE CONCAT(#{regioncode},'%') </if>
    <if test="time != null and time != ''\" > and DATE_FORMAT(#{time}, '%Y-%m-%d %H:%i:%s') = timeBase </if>
    <if test="stationkey != null and stationkey != ''" > and stationKey = #{stationkey} </if>
    group by stationKey
    )  t2 on t1.stationKey = t2.stationKey and t1.timeBase = t2.latest_timestamp

      join station_info i on i.stationKey = t2.stationKey
      
     where 1=1 
      <if test="orgid != null and orgid != ''" > and i.orgid LIKE CONCAT(#{orgid},'%') </if>
    
    
      order by code 
"""

 
return db.select (sql); 
